<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet">
    <script src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js"></script>
    <title>登录</title>
</head>
<body>
<div class="row">
    <div class="col-md-4"></div>
    <div class="col-md-4">
        <div class="panel panel-primary">
            <div class="panel-body">
                <div class="row">
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="form-group">
                            <div class="col-md-10">
                                <div class="control-group">
                                    <div class="controls">
                                        <div class="">
                                            <input type="text" style="border: 1px;"  id="userName" name="userName" placeholder="请随便输入一个昵称" onkeyup="keyEnter(event)">
                                            <a class="btn btn-success btn-sm" onclick="login()" >登录</a>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-4"></div>
</div>
<script>
    function login() {
        var username = $("#userName").val();
        if (username === ""){
            alert("请输入一个昵称");
            return;
        }
        window.location.href = "http://localhost:8081/chat.html?username=" + username;
    }
    function keyEnter(event) {
        if (event.keyCode == "13") {
            login();
        }
    }
</script>
</body>
</html>